home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
crsbas.zip
/
CROSSBAS.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-12-01
|
56KB
|
1,408 lines
'┌─────────────────────────────────────────────────────────────────────┐
'└── beginning of crossbas.bas ────────────────────────────────────────┘
'┌─────────────────────────────────────────────────────────────────────┐
'│ CrossBas.bas │
'│ │
'│ This program will scan a Power-BASIC source file and create a cross-│
'│ reference table of variable names and labels. To do this we must │
'│ first read in all words in the file. We can skip all text to the │
'│ right of "REM" or "'" remark identifiers. After words are read in, │
'│ we must compare them with PBASIC reserved words and metastatements. │
'│ Finally, we alphabetize the remaining words and print them out, one │
'│ word to a line, followed by the line number(s) where these words │
'│ were found. The list will bs sorted without regard to case. │
'│ │
'│ Command Line Switches: │
'│ /BW Set screen colors to Black & White │
'│ /U Print all cross-reference variables in upper-case. │
'│ /P Print page headers and footers. │
'│ /S Print cross-reference list to the screen as well as to file. │
'│ /L:n Left margin n spaces. │
'│ /W:n Word array dimension over-ride. │
'│ │
'│ │
'│ Modification History: │
'│ │
'│ Uploaded CrossBas version 1.00P to Compuserve PCVENB, Spectra │
'│ forum. Converted for Power-BASIC. 12/ 1/90 │
'│ │
'│ Added /bw switch to allow black and white screen color override. │
'│ Also, added color to default screen. 12/ 1/90 │
'│ │
'│ Uploaded CrossBas version 1.00 to CompuServe BPROGA forum, LIB 9. │
'│ (Originally written for and in Turbo-BASIC.) │
'│ │
'│ KEYWORDS: CROSS-REFERENCE, TABLE, LIST, NON-RESERVED WORDS │
'│ │
'│ Description: CrossBas will read in a Turbo-BASIC source file and │
'│ create an alphabetized cross-reference listing of non- │
'│ reserved words, i.e., variable, sub-program, function and │
'│ label names, along with the physical line number(s) where they │
'│ appear. The list is printed to file. Handy for cleaning │
'│ up unused variable names, labels, etc. 11/13/89 │
'│ │
'│ You are free to use this program as you wish. If you find any │
'│ problems with if, please let me know about it. If you have any │
'│ suggestions as to how to improve is, also, I'd appreciate your │
'│ help. │
'│ │
'│ │
'│ Lester L. Noll CompuServe id: 72250,2551 │
'│ copyright (c) 11/13/89, 1990 │
'│ │
'└─────────────────────────────────────────────────────────────────────┘
Title$ ="CrossBas.bas"
Ver$ ="1.00P"
Copyright$ ="Copyright (c) 11/13/90, Lester L. Noll"
CisId$ ="72250,2551"
'┌── main program ─────────────────────────────────────────────────────┐
Main:
GOSUB Initialize 'Initialize screen, integers.
GOSUB InitScreen 'Put up init screen.
GOSUB ReadCmdLine 'Read the DOS command line.
GOSUB OpenFiles 'Open source files and check name
' validity.
GOSUB CalcFileNames 'Parse filename from full path.
GOSUB ReadDefaults 'Read defaults from default file.
' GOSUB CheckStringSpace 'Check there is enough string space
' for infile words.
'(Took this out for PBASIC version)
GOSUB CalcWordArraySize 'Calc word array dimension.
GOSUB PrintScreenTop 'Print top of screen report.
GOSUB ReadAndParseData 'Read source file lines and parse
' them into words.
GOSUB PrintScreen1 'Print read and parse report.
GOSUB Compare 'Compare source words with Power-
' BASIC reserved words.
GOSUB PrintScreen2 'Print compare report.
GOSUB SortWords 'Sort non-reserved words.
GOSUB PrintScreen3 'Print sort report.
GOSUB PrintList 'Print sorted words to file.
GOSUB PrintReportBtm 'Print summary report to file.
GOSUB PrintScreen4 'Print print-list report.
CLOSE
DELAY 1
CALL FlushKeyBuf
END
'└─────────────────────────────────────────────────────────────────────┘
'─── initialize ────────────────────────────────────────────────────────
Initialize:
$DYNAMIC 'All arrays default to dynamic. They
' can be erased after you're finished
' using them.
SCREEN 0,1: WIDTH 80: CLS 'Color board, 80 columns.
CLOSE 'Close all open files.
DEFINT A-Z 'Default all numbers to integer.
FG =14 'Foreground color.
BG =1 'Background color.
KEY OFF 'Turn BASIC soft keys off.
DIM SaveRow(10), SaveCol(10) 'Screen location arrays.
ON ERROR GOTO MemoryError 'Memory and other error trap.
RETURN
'─── print init screen ─────────────────────────────────────────────────
InitScreen:
COLOR FG,BG
LOCATE 10,18
PRINT "Initializing CrossBas. Please wait ";
COLOR FG+16,BG 'Blink screen.
PRINT "..."
COLOR FG,BG
RETURN
'─── include files ─────────────────────────────────────────────────────
$INCLUDE "crossbas.inc" 'CrossBas subprograms file.
'─── read command line ─────────────────────────────────────────────────
ReadCmdLine: 'Read the DOS command line and use variables found
' there as the input PBASIC source file, the output
' cross-reference table file, and the '/u,' '/s,'
' '/l:n,' '/w:n,' and '/p' switches. The first
' variable that doesn't start with one of the switch
' strings is assumed to be the source. If a second
' such string is found, it is assumed to be the output
' file. If no output file is found, the input filename
' appended with '.cb' becomes the output filename.
' Other than input/output filename sequence, other
' parameters can be entered in any order.
ON ERROR GOTO MemoryError 'Memory and other errors trap.
PageFlag =0 'Print page breaks and headers (1).
ScreenFlag =0 'Print list to screen also (1).
UcaseFlag =0 'Print list in upper-case (1).
LMarginMax =8 'Max left margin value.
WordDimFlag =0 'Word array dimension over-ride flag.
WordArrayDim =0 'Word array dimension over-ride.
InFile$ ="" 'Input (source) file name and path.
OutFile$ ="" 'Output file name and path.
CALL DimCmdLine(DimCmd) 'Get number of parameters on cmd line.
DIM Parameter$(1:DimCmd) 'Max number of cmd line parameters.
CALL ParseCmdLine(Parameter$()) 'Get command line parameters.
FOR I = 1 TO DimCmd
SELECT CASE LEFT$(UCASE$(Parameter$(I)),2)'Check the left two
' characters of the DOS command
' line pa